﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SanJ.FreeCare.Migrations
{
    /// <inheritdoc />
    public partial class AddDetail : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MedicationExtInfo_AppMedications_MedicationId",
                table: "MedicationExtInfo");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AppMedications",
                table: "AppMedications");

            migrationBuilder.RenameTable(
                name: "AppMedications",
                newName: "fc_Medications");

            migrationBuilder.AddPrimaryKey(
                name: "PK_fc_Medications",
                table: "fc_Medications",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "fc_ObservationDefinitions",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Spell = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ParentId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    Code = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsVaild = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PermittedDataType = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Category = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UiControlType = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PermittedUnit = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PreferredReportName = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ExtraProperties = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_fc_ObservationDefinitions", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddForeignKey(
                name: "FK_MedicationExtInfo_fc_Medications_MedicationId",
                table: "MedicationExtInfo",
                column: "MedicationId",
                principalTable: "fc_Medications",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MedicationExtInfo_fc_Medications_MedicationId",
                table: "MedicationExtInfo");

            migrationBuilder.DropTable(
                name: "fc_ObservationDefinitions");

            migrationBuilder.DropPrimaryKey(
                name: "PK_fc_Medications",
                table: "fc_Medications");

            migrationBuilder.RenameTable(
                name: "fc_Medications",
                newName: "AppMedications");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AppMedications",
                table: "AppMedications",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_MedicationExtInfo_AppMedications_MedicationId",
                table: "MedicationExtInfo",
                column: "MedicationId",
                principalTable: "AppMedications",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
